﻿package com.designoutput.ui.controls
{
    import flash.display.*;
    import flash.events.*;
    import flash.text.*;

    public class SelectItem extends Sprite
    {
        internal var bg:Sprite;
        internal var title:TextField;
        internal var selected:Boolean = false;

        public function SelectItem($title:String, $name:String, $width:int):void
        {
            this.name = $name;
            this.bg = new Sprite();
            var _loc_4:int = 0;
            this.bg.y = 0;
            this.bg.x = _loc_4;
            this.bg.graphics.beginFill(3355443);
            this.bg.graphics.drawRect(0, 0, $width - 2, 18);
            this.bg.graphics.endFill();
            this.bg.alpha = 0;
            addChild(this.bg);
            this.title = new TextField();
            this.title.defaultTextFormat = new TextFormat("Arial, Helvetica, San-serif", 12, 0, false, false, false, null, null, "left");
            this.title.multiline = false;
            this.title.selectable = false;
            this.title.autoSize = TextFieldAutoSize.LEFT;
            this.title.height = 16;
            this.title.text = $title;
            this.title.x = 2;
            this.title.y = 0;
            addChild(this.title);
            this.addEventListener(MouseEvent.ROLL_OVER, this.MouseOver);
            this.addEventListener(MouseEvent.ROLL_OUT, this.MouseOut);
        }

        private function MouseOut(event:MouseEvent) : void
        {
            if (!this.selected)
            {
                this.bg.alpha = 0;
            }
        }

        private function MouseOver(event:MouseEvent) : void
        {
            if (!this.selected)
            {
                this.bg.alpha = 0.4;
            }
        }

        public function Select(param1:Boolean = true):void
        {
            this.selected = param1;
            if (param1)
            {
                this.bg.alpha = 0.5;
            }
            else
            {
                this.bg.alpha = 0;
            }
        }

        public function get text() : String
        {
            return this.title.text;
        }

    }
}
